import json

import scrapy


class TranslateSpider(scrapy.Spider):
    name = "translate"
    allowed_domains = ["fanyi.baidu.com"]
    start_urls = ["https://fanyi.baidu.com/sug/"]
    #
    # def parse(self, response):
    #     pass
    def start_requests(self):
        url="https://fanyi.baidu.com/sug"
        data={
            'kw':'final'
        }
        yield scrapy.FormRequest(url=url,formdata=data,callback=self.parse_second)

    def parse_second(self,response):
        print(json.loads(response.text))